#ifndef COOLPOOL_SIMULATION_SIMOBJECTS_BALLCOLLISIONTIMEFINDER_H_
#define COOLPOOL_SIMULATION_SIMOBJECTS_BALLCOLLISIONTIMEFINDER_H_

#include "ObjectTypes.h"
#include "BallCollisionDetectors.h"
#include "CollisionTimeFinder.h"

namespace coolpool
{
	// CollisionTime finder for ball objects
	class BallCollisionTimeFinder: public CollisionTimeFinder
	{
	public:

		BallCollisionTimeFinder()
		{
		}

		virtual ~BallCollisionTimeFinder()
		{
		}

		// Overrides:
		const Collision * findCollisionTime(/* const */DynamicEntity * dynamic_entity, /* const */Entity * entity, double time_step, double lambda) throw (UnexpectedInputException)
		{
			const Collision * output = NULL; // No collision detected.

			switch (entity->getType())
			{
				case CP_BALL:
				{
					output = findCollisionTimeWithDetectorDynamic(bb_detector, dynamic_entity, static_cast<DynamicEntity*> (entity), time_step, lambda);
					break;
				}
				case CP_REC:
				{
					output = findCollisionTimeWithDetectorStatic(br_detector, dynamic_entity, entity, time_step, lambda);
					break;
				}
				default:
					// Uknown objects are ignored
					break;
			}
			return output;
		}

	private:

		BallBallCollisionDetector bb_detector;
		BallRectangleCollisionDetector br_detector;
	};
}
#endif
